package speed2010.andreza.vspeed.ontologies;

import java.io.Serializable;

public class OntologyConcept implements Serializable, Comparable {
	
	private String name;
	private int frequency;
	
	public OntologyConcept(String name, int frequency)
	{
		this.name = name;
		this.frequency = frequency;
	}
	
	public OntologyConcept(String name)
	{
		this.name = name;
		this.frequency = 1;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getFrequency() {
		return frequency;
	}

	public void setFrequency(int frequency) {
		this.frequency = frequency;
	}
	
	public void updateFrequency()
	{
		this.frequency = this.frequency + 1;
	}
	
	public int compareTo(Object o)
	{
		OntologyConcept anotherConcept = (OntologyConcept) o;
		if(this.getFrequency() < anotherConcept.getFrequency())
		{
			return 1;
		}
		else if(this.getFrequency() == anotherConcept.getFrequency())
		{
			return 0;
		}
		else
		{
			return -1;
		}
	}
	
	public boolean equals(Object o)
	{
		OntologyConcept anotherConcept = (OntologyConcept) o;
		if(this.name.equals(anotherConcept.name))
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	
	public String toString()
	{
		return this.getName() + "(" + this.getFrequency() + ")";
	}

}
